home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: READ THIS!!!!!!!!!!!
- Date: 02 Feb 1996 01:18:45 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Feb1201845@g7240065.bridge.bst.bls.com>
- References: <4em5fs$a86@ixnews4.ix.netcom.com>
- <4er65q$d8v@usenet1.sjc.in.sel.sony.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: Victor Marilao's message of 1 Feb 1996 20:00:58 GMT
-
- In article <4er65q$d8v@usenet1.sjc.in.sel.sony.com> Victor Marilao <victorm@sec.sel.sony.com> writes:
-
- : jeremyx@ix.netcom.com(Jeremy Johnston ) wrote:
- :>
- :> ok....now that I have your attention i need some help.
- :> I can't get the following command to work & the compiler says that the
- :> constant has too many characters.
- :>
- :> char dos;
- :> if(dos=='dir')
- :> goto b;
- :>
- :> How can i do this to get it to work? please help,I know you can.
- :>
- :>
-
- : Try this:
-
- : #include "stdio.h"
- : #include "string.h"
-
- : main()
- : {
- : char *dos;
- : // strcpy(dos, "dir"); // Uncomment to test for a valid
- : match
-
- Uncomment this for some strange behaviour.
-
- : if (strcmp(dos, "dir") == 0)
- : printf("Its a match");
- : }
-
- : E-mail me if you need an explanation.
-
- Yes I need an explanation on why you think this will work.
- The next question from this person will be:
-
- #include "string.h"
-
- int
- main(void)
- {
- char* str;
- strcpy(str, "SomeString");
-
- return 0;
- }
-
- Why does this crash (my operating system - it was in dos ;') ?
-
- Because you didn't allocate space for str;
-
- Regards
-
- -A.
-
-
-
-
- --
- | A.Champion |
-